import request from '@/utils/request'
// 课程管理模块api文件
export default{
  // 1.发布课程第一步：保存课程基本信息
  saveCourseInfo(courseInfo) {
    return request({
      url: '/admin/edu/course/save-course-info',
      method: 'post',
      data: courseInfo
    })
  },
  // 课程基本信息
  getCourseInfo(courseId) {
    return request({
      url: `/admin/edu/course/get-course-info/${courseId}`,
      method: 'get'
    })
  },
  // 更新课程基本信息
  updateCourseInfo(courseInfo, courseId) {
    return request({
      url: `/admin/edu/course/update-course-info/${courseId}`,
      method: 'put',
      data: courseInfo
    })
  },
  // 查询课程分页数据
  list(pageNum, pageSize, query) {
    return request({
      url: `/admin/edu/course/list/${pageNum}/${pageSize}`,
      method: 'get',
      params: query
    })
  },
  // 新增章节
  saveChapter(chapter) {
    return request({
      url: `/admin/edu/chapter/save`,
      method: 'post',
      data: chapter
    })
  },
  listNestedChapters(courseId) {
    return request({
      url: `/admin/edu/chapter/listNestedChapters/${courseId}`,
      method: 'get'
    })
  },
  get(id) {
    return request({
      url: `/admin/edu/chapter/get/${id}`,
      method: 'get'
    })
  },
  update(chapter) {
    return request({
      url: `/admin/edu/chapter/update`,
      method: 'put',
      data: chapter
    })
  },
  delete(id) {
    return request({
      url: `/admin/edu/chapter/remove/${id}`,
      method: 'delete'
    })
  },
  //  查询要发布课程数据
  getCoursePublish(id) {
    return request({
      url: `/admin/edu/course/get-course-publish/${id}`,
      method: 'get'
    })
  },
  coursePublish(id) {
    return request({
      url: `/admin/edu/course/course-publish/${id}`,
      method: 'put'
    })
  }
}
